/*
 * i3.hpp
 *
 *  Created on: Jul 2, 2012
 *      Author: bjames
 */

#ifndef _GOVT_I3_HPP_
#define _GOVT_I3_HPP_

/*******************************************************************************
 ** Government Sanctioned Espionage RPG Server                                **
 ** http://www.government-sanctioned.us/                                      **
 **===========================================================================**
 ** Name: i3.hpp                                                              **
 ** Description:                         **
 **                                                                           **
 ** Open Source Initiative (OSI) Approved License                             **
 **                                                                           **
 ** The contents of this file are subject to the terms of the                 **
 ** Common Development and Distribution License, Version 1.0 only             **
 ** (the "License").  You may not use this file except in compliance          **
 ** with the License.                                                         **
 **                                                                           **
 ** You can find a copy of the license in the LICENSE file within             **
 ** this distribution or at $WIKI/display/GOVT/License-software.              **
 ** Software distributed under the License is distributed on an "AS IS"       **
 ** basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.           **
 ** See the License for the specific language governing permissions           **
 ** and limitations under the License.                                        **
 **                                                                           **
 ** When distributing Covered Code, include this CDDL header in each          **
 ** file and include the License file at $GAME_DIR/LICENSE.                   **
 ** If applicable, add the following below this header, with the indicated    **
 ** fields enclosed by brackets "[]" replaced with your own identifying       **
 ** information: Portions Copyright [yyyy] [name of copyright owner]          **
 **                                                                           **
 ** Copyright (c) 2009-2012  Barry Gian James <gian@gamingods.net>            **
 ** All rights reserved.                                                      **
 ******************************************************************************/
// $HeadURL$
// Modified $Date$ by $Author$
// $Id$

enum class I3ACL
{
	Undefined,
	None,
	Normal,
	Handler,
	Control
};

enum class I3_Error
{
	UnknownDestination,
	Unimplemented,
	UnknownPacket,
	UnknownSource,
	BadPacket,
	BadProtocol,
	Denied
};

enum class I3_PacketType
{
	Tell,
	EmoteTo,
	WhoRequest,
	WhoReply,
	FingerRequest,
	FingerReply,
	LocateRequest,
	LocateReply,
	ChannelReply,
	ChanM,
	ChanE,
	ChanT,
	ChannelAdd,
	ChannelRM,
	ChannelAdmin,
	ChanFilterRequest,
	ChanFilterReply,
	ChanWhoRequest,
	ChanWhoReply,
	ChannelListen,
	ChanUserRequest,
	ChanUserReply,
	NewsReadRequest,
	NewsPostRequest,
	NewsGroupListRequest,
	Mail,
	MailAck,
	FileListRequest,
	FileListReply,
	FilePut,
	FilePutAck,
	FileGetRequest,
	FileGetReply,
	AuthRequest,
	AuthReply,
	Cache,
	Error,
	StartupRequest,
	StartupReply,
	Shutdown,
	Mudlist,
	OOBRequest,
	OOBBegin,
	OOBEnd
};
extern char * I3ServiceString[];

enum class I3_Service : uint16_t
{
	Tell = 0x0001, Beep = 0x0002, EmoteTo = 0x0004, Who = 0x0008,
	Finger = 0x0010, Locate = 0x0020, Channel = 0x0040, News = 0x0080,
	Mail = 0x0100, File = 0x0200, Auth = 0x0400, UCache = 0x0800
};

struct i3CmdAlias
{
	std::string	name;
};
struct i3Cmd
{
	std::vector<i3CmdAlias>	aliases;
	std::string	name;
	int			lvl;
	bool		connected;
};
struct i3HelpData
{
	std::string	name;
	std::string	txt;
	int			lvl;
};
struct i3ColorData
{
	std::string	name;
	std::string	mudtag;
	std::string	i3tag;
	std::string	i3fish;
};
struct i3RouterData
{
	std::string	name;
	std::string	ip;
	int			port;
	int			conat;	// reconnect attempts
};
struct i3UcacheData
{
	std::string	name;
	int			gender;
	time_t		time;
};
struct i3CharData
{
	std::string	replyName;
	std::string	listen;
	std::string	denied;
	std::string	tellHistory;
	int			flags;
	int			perms;
	std::vector<std::string>	ignoreList;
};
struct i3PktHeader
{
	char	origMud[256];
	char	origUser[256];
	char	destMud[256];
	char	destUser[256];
};
struct i3ChannelData
{
	std::string	localName;
	std::string	hostMUD;
	std::string	i3Name;
	std::string	layoutM;
	std::string	layoutE;
	int			status;
	int			perms;
	std::string	history;
	long		flags;
};

extern	std::list<i3Cmd>	i3CmdList;
extern 	std::vector<i3UcacheData>	i3UcacheList;
extern 	std::vector<std::string>		i3BanList;
extern 	std::vector<i3ChannelData> i3ChannelList;
extern 	std::vector<i3HelpData>	i3HelpList;
extern 	std::vector<i3ColorData>	i3ColorList;
extern 	std::vector<i3RouterData>	i3RouterList;

typedef void (i3Function)(i3CharData * d, char * arg);

#define i3Command(cmd) void (cmd)(i3CharData * d, char * arg)

class i3MUD
{
public:
	i3MUD();

	bool		isConnected();

private:
	int			status;
	std::string	name;
	std::string	ip;
	std::string	version;
	std::string	driver;
	std::string	type;
	std::string	openStatus;
	std::string	adminEmail;
	std::string	telnet;
	int			playerPort;
	int			imudTCPPort;
	int			imudUDPPort;
	uint16_t	svcFlags;
	// optional stuff - may take out later
	std::string	banner;
	std::string	motd;
	std::string	web;
	std::string	time;

	bool		autoconnect;
	int			idMudlist;
	int			idChanlist;
	int			minLvl;
	int			ctrlLvl;
	int			handlerLvl;

};



#endif /* _GOVT_I3_HPP_ */
